package com.peanutplan.blog.constant;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * Created by BlueT on 2017/3/3.
 */
@Component
public class WebConst {
    /**
     * 存储安装信息的配置文件名称
     */
    public static final String INSTALL_FILE_CONF = "install.lock";

    public static Map<String, String> initConfig = new HashMap<>();

    public static String LOGIN_SESSION_KEY = "login_user";

    public static final String USER_IN_COOKIE = "S_L_ID";

    /**
     * aes加密加盐
     */
    public static String AES_SALT = "0123456789abcdef";

    /**
     * 最大获取文章条数
     */
    public static final int MAX_POSTS = 9999;

    /**
     * 最大页码
     */
    public static final int MAX_PAGE = 100;

    /**
     * 文章最多可以输入的文字数
     */
    public static final int MAX_TEXT_COUNT = 200000;

    /**
     * 文章标题最多可以输入的文字个数
     */
    public static final int MAX_TITLE_COUNT = 200;

    /**
     * 点击次数超过多少更新到数据库
     */
    public static final int HIT_EXCEED = 10;

    /**
     * 上传文件最大1M
     */
    public static Integer MAX_FILE_SIZE = 1048576;

    /**
     * 要过滤的ip列表
     */
    public static final Set<String> BLOCK_IPS = new HashSet<>(16);
    
    /**
     * 默认上传的地址
     */
    public static String defaultProfile;
    public static String defaultArticleCover;
    public static String defaultUploadBasedir;
    
    @Value("${default_profile}")
    public void setDefaultProfile(String defaultProfile) {
		WebConst.defaultProfile = defaultProfile;
	}
    @Value("${default_article_cover}")
	public void setDefaultArticleCover(String defaultArticleCover) {
		WebConst.defaultArticleCover = defaultArticleCover;
	}
    @Value("${default_upload_basedir}")
	public void setDefaultUploadBasedir(String defaultUploadBasedir) {
		WebConst.defaultUploadBasedir = defaultUploadBasedir;
	}
}
